﻿using CarAppClient.Consts;
using CarAppClient.Controls.MessageUsercontrols;
using CarAppClient.Extension;
using CarAppClient.Helpers;
using CarAppClient.ViewModels;
using D.UtilCore.Dtos;
using System.Collections.ObjectModel;
using DelegateCommand = D.WPF.MVVM.EventUtil.DelegateCommand;
using CarAppClient.Views.CarParts.ViewModels.CarParts;
using CarAppDto.CarParts.CarPartsDtos;
using SqlSugar;
using CarAppClient.Views.CarParts;
using System.Linq;
using CarAppClient.Views.Rule.Views;
using CarAppClient.Views.CarType.Views.Brand;
using CarAppClient.Views.CarType.ViewModels.CarType;
using CarAppDto.CarType.BrandDtos;
using CarAppDto.Rule.RuleConfigDtos;
using CarAppDto.CarParts.CarPartsTypeDtos;
using CarAppDto.Common;

namespace CarAppClient.Views.RuleConfig.ViewModels.RuleConfig
{
    public class RuleConfigDetailsModifyViewModel : BaseModifyViewModel<Page_RuleConfigDetails_Modify>
    {
        #region 加载页面数据
        RuleConfigDetails _ruleConfigDetails;
        public RuleConfigDetailsModifyViewModel(Page_RuleConfigDetails_Modify owner, string? id, RuleConfigDetails ruleConfigDetails, ViewStatus? viewStatus) : base(owner, id, viewStatus)
        {
            _ruleConfigDetails = ruleConfigDetails;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="repRuleConfig"></param>
        protected async override void LoadData()
        {
           
        }
        #endregion

        #region 新增、修改 参数
        private string? position;
        /// <summary>
        /// 位置
        /// </summary>
        public string? Position
        {
            get { return position; }
            set { position = value; RaisePropertyChanged(); }
        }

        private string? ruleValue;
        /// <summary>
        /// 位置
        /// </summary>
        public string? Value
        {
            get { return ruleValue; }
            set { ruleValue = value; RaisePropertyChanged(); }
        }

        #endregion

        #region 保存事件
        // 委托定义
        public delegate void InformationRequestedHandler(object sender, InformationEventArgs<RuleConfigDetails> e);
        public event InformationRequestedHandler InformationRequested;
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="vm"></param>
        protected override async void Submit(object? obj)
        {
            RuleConfigDetails ruleConfigDetails = new RuleConfigDetails();
            ruleConfigDetails.Position = Position;
            ruleConfigDetails.Value = Value;

            this.FromClose();
            InformationRequested?.Invoke(this, new InformationEventArgs<RuleConfigDetails>(ruleConfigDetails));
        }
        #endregion
 
    }
}
